home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / cert / trk3_eg / menurght / calldlls.frm (.txt) next >
Encoding:
Visual Basic Form  |  1993-08-09  |  3.1 KB  |  90 lines

  1. VERSION 2.00
  2. Begin Form frmCallDlls 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Right Mouse"
  5.    ClientHeight    =   3750
  6.    ClientLeft      =   1455
  7.    ClientTop       =   1665
  8.    ClientWidth     =   5505
  9.    ClipControls    =   0   'False
  10.    Height          =   4155
  11.    Left            =   1395
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   3750
  15.    ScaleWidth      =   5505
  16.    Top             =   1320
  17.    Width           =   5625
  18.    Begin Image Image1 
  19.       Height          =   1695
  20.       Left            =   0
  21.       Top             =   2040
  22.       Width           =   5535
  23.    End
  24.    Begin Image ImgArea 
  25.       Height          =   2055
  26.       Index           =   0
  27.       Left            =   0
  28.       Top             =   0
  29.       Width           =   2655
  30.    End
  31.    Begin Image ImgArea 
  32.       Height          =   2055
  33.       Index           =   1
  34.       Left            =   2640
  35.       Top             =   0
  36.       Width           =   2895
  37.    End
  38.    Begin Menu mnuTest 
  39.       Caption         =   "Test"
  40.       Visible         =   0   'False
  41.       Begin Menu mnuTest1 
  42.          Caption         =   "Test1"
  43.       End
  44.       Begin Menu mnuTest2 
  45.          Caption         =   "Test2"
  46.       End
  47.       Begin Menu mnuTest3 
  48.          Caption         =   "Test3"
  49.       End
  50.       Begin Menu mnuTest4 
  51.          Caption         =   "Test4"
  52.       End
  53.    End
  54. Option Explicit
  55. Sub Form_Load ()
  56.     Show                ' Make sure this form has an hWnd, etc.
  57.     Load frmMenus
  58. End Sub
  59. Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
  60.     End
  61. End Sub
  62. Sub Image1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  63. If Button = 2 Then
  64. frmcallDlls.PopupMenu mnutest
  65. End If
  66. End Sub
  67. Sub ImgArea_MouseDown (index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  68. 'The index grabs the control index of control array
  69. 'Button grabs which button clicked
  70. 'True false if Shift key down
  71. Dim IX As Integer
  72. Dim IY As Integer
  73. Dim hMenu As Integer
  74. Dim hSubMenu As Integer
  75. Dim R As Integer       'response variable for DLL call
  76. Dim menRect As Rect       'Establishes boundary for right click
  77.     If Button And 2 Then     'Compares two Bitpos with and (eg 2 and 2 equal True)
  78.     ScaleMode = TWIPS
  79.     menRect.Left = 0                                          'Establishes boundary for right click
  80.     menRect.Top = 0                                             'Establishes boundary for right click
  81.     menRect.Right = Screen.Width / Screen.TwipsPerPixelX          'Establishes boundary for right click
  82.     menRect.Bottom = Screen.Height / Screen.TwipsPerPixelY           'Establishes boundary for right click
  83.     IX = (X + frmcallDlls.Left + imgarea(index).Left) \ Screen.TwipsPerPixelX
  84.     IY = (Y + frmcallDlls.Top + imgarea(index).Top + (frmcallDlls.Height - frmcallDlls.ScaleHeight)) \ Screen.TwipsPerPixelY
  85.     hMenu = GetMenu(frmMenus.hWnd)     'Get menu from form
  86.     hSubMenu = GetSubMenu(hMenu, index)   'Create a drop down submenu
  87.     R = TrackPopupMenu(hSubMenu, 2, IX, IY, 0, frmMenus.hWnd, menRect)
  88.     End If
  89. End Sub
  90.